<template>
  <div class="common-layout">
    <el-container class="layout-container">
      <el-aside width="220px" class="sidebar">
        <div class="sidebar-content">
          <el-button
            type="primary"
            @click="goToCreatePage"
            class="function-btn create-btn"
          >
            <el-icon><Plus /></el-icon>
            创建产品批号
          </el-button>

          <!-- 新增的浏览产品批号按钮 -->
          <el-button
            type="success"
            @click="goToBatchList"
            class="function-btn batch-list-btn"
          >
            <el-icon><List /></el-icon>
            产品批号信息
          </el-button>

          <!-- 新增的批发商入场请求按钮 -->
          <el-button
            type="warning"
            @click="goToWholesalerRequest"
            class="function-btn wholesaler-btn"
          >
            <el-icon><ShoppingCart /></el-icon>
            批发商入场请求
          </el-button>
        </div>
      </el-aside>

      <el-main class="main-content">
        <div class="page-header">
          <h1>屠宰企业管理主页</h1>
        </div>

        <el-card class="welcome-card" shadow="hover">
          <template #header>
            <div class="card-header">
              <el-icon><House /></el-icon>
              <span>欢迎使用屠宰企业管理系统</span>
            </div>
          </template>

          <div class="welcome-content">
            <p>请选择左侧的功能按钮开始操作：</p>
            <ul>
              <li>
                <el-icon><Check /></el-icon>
                点击"创建产品批号"进入产品批号创建页面
              </li>
              <li>
                <el-icon><Check /></el-icon>
                点击"产品批号信表"查看和管理产品批号
              </li>
              <li>
                <el-icon><Check /></el-icon>
                点击"批发商入场请求"处理批发商的入场申请
              </li>
            </ul>
          </div>
        </el-card>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import { useRouter } from "vue-router";
import {
  Plus,
  House,
  Check,
  List,
  ShoppingCart,
} from "@element-plus/icons-vue";

export default {
  name: "SlaughterEnterprise",
  components: {
    Plus,
    House,
    Check,
    List,
    ShoppingCart,
  },
  setup() {
    const router = useRouter();

    const goToCreatePage = () => {
      router.push("/ent/slaghter/create");
    };

    const goToBatchList = () => {
      router.push("/ent/slaghter/batch-list");
    };

    const goToWholesalerRequest = () => {
      router.push("/ent/slaghter/wholesaler-request");
    };

    return {
      goToCreatePage,
      goToBatchList,
      goToWholesalerRequest,
    };
  },
};
</script>

<style scoped>
.common-layout {
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ed 100%);
}

.layout-container {
  height: 100%;
}

.sidebar {
  background: linear-gradient(180deg, #304156 0%, #2b3847 100%);
  padding: 20px;
  display: flex;
  align-items: flex-start;
}

.sidebar-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px; /* 统一间距 */
}

.function-btn {
  width: 100%;
  height: 48px;
  font-size: 16px;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  margin: 0 !important; /* 清除默认边距 */
}

.create-btn {
  background: linear-gradient(135deg, #409eff 0%, #337ecc 100%);
}

.batch-list-btn {
  background: linear-gradient(135deg, #67c23a 0%, #529b2e 100%);
}

.wholesaler-btn {
  background: linear-gradient(135deg, #e6a23c 0%, #cf9236 100%);
}

.function-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.function-btn .el-icon {
  margin-right: 8px;
  font-size: 18px;
}

.main-content {
  padding: 30px;
  background: transparent;
}

.page-header {
  margin-bottom: 30px;
}

.page-header h1 {
  margin: 0;
  color: #304156;
  font-size: 28px;
  font-weight: 600;
}

.welcome-card {
  max-width: 600px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
}

.card-header {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
  color: #304156;
}

.card-header .el-icon {
  margin-right: 8px;
  color: #409eff;
}

.welcome-content {
  line-height: 1.6;
  color: #606266;
}

.welcome-content p {
  margin-bottom: 16px;
  font-size: 15px;
}

.welcome-content ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.welcome-content li {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.welcome-content li:hover {
  background: #ecf5ff;
  transform: translateX(5px);
}

.welcome-content li .el-icon {
  margin-right: 8px;
  color: #67c23a;
  font-size: 14px;
}

@media (max-width: 768px) {
  .sidebar {
    width: 100% !important;
    height: auto;
  }

  .main-content {
    padding: 20px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .function-btn {
    height: 44px;
    font-size: 14px;
  }
}
</style>
